Skip to content

test(libkernel): pick a foreign process group guest_kill cannot own - #7739

Open
ionut27001 wants to merge 1 commit into
boykopovar:mainfrom
ionut27001:test/guest-kill-foreign-group
Open

ionut27001 wants to merge 1 commit into
boykopovar:mainfrom
ionut27001:test/guest-kill-foreign-group

Conversation

@ionut27001

Copy link
Copy Markdown
Contributor

What

guest_kill fails now and then on the Windows job with Exit code 0xc0000409 (an abort()) and no message, for example job 117639443072: the first attempt of a build that only held #6218 (AGC storage images), which passed on the rerun.

The test checks that killpg on a process group other than its own fails with ESRCH, using self + 1 and the fixed number 1000. getpid returns the host process id (GetCurrentProcessId, ::getpid). Windows hands out process ids as multiples of 4 and reuses them, so the test process can get id 1000. Group 1000 is then the caller's own: kill(-1000, 0) succeeds, as the test itself requires a few lines earlier for killpg(self, 0), and KillpgFails(1000, 0, 3) aborts. With the process id forced to 1000 and the values printed before Require, the run stopped at:

killpg(1000, 0) returned 0 errno 0, expected -1 errno 3 (getpid 1000)

The test now uses self + 1000, which is never the caller's group. kill and killpg are not changed. Test-only.

Tested

AMD Ryzen 7 5800X3D (8 cores, 16 threads), Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7 (UCRT), Release, main 676d42396 (the test file and Signals.cpp are the same on current main 72a3d9f2a).

Process id 1000 cannot be obtained on this machine: a System thread holds client id 1000 (process and thread ids come from one table), and 100,000 suspended cmd.exe starts never got it. So each run started the test suspended, set ClientId.UniqueProcess in its main thread's TEB (the field GetCurrentProcessId reads) and resumed it.

main this change
getpid() = 1000, 200 runs 200 of 200 fail 0 of 200 fail
getpid() = 4, 996, 999, 1001, 1004, 2000, 4000 and 65532, 20 runs each 0 of 160 fail 0 of 160 fail
real process ids, 24 copies together, 10 rounds 0 of 240 fail 0 of 240 fail

The failing runs exit with 0xc0000409, as on CI. In the Build runs from 15 to 19 October (215 failed Windows jobs out of roughly 1,200 Windows test jobs), guest_kill failed once, the job above. It did not fail on Linux in those runs; Linux hands out process ids in increasing order, so 1000 comes back only after the counter wraps.

Revert check: with killpg changed to succeed for any group when the signal is 0, the test fails 10 of 10 runs, with or without this change.

On 72a3d9f2a, ctest -R ^guest_kill$ passes 3 of 3 and python tools/check_conventions.py passes.

Not checked: Linux and macOS, though the change is platform-independent test code.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a (CPU test)
  • AI-assisted: yes (Claude Code)

guest_kill requires killpg(1000, ...) to fail with ESRCH, but getpid
returns the host process id. When Windows gives the test process id
1000, group 1000 is the caller's own, killpg succeeds as the test itself
requires for killpg(self, 0), and Require aborts with 0xc0000409. Use
self + 1000, which is never the caller's group.
@github-actions

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestKill.cpp

@ionut27001

Copy link
Copy Markdown
Contributor Author

On the overlap report: #6044 only renames core/libs/tests/GuestKill.cpp to core/libs/tests/process/GuestKill.cpp (+0/-0, per its file list); it does not change the test, so there is no overlap with this one-line change.

@adriadam10 adriadam10 self-assigned this Oct 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants